package com.vcms.utility.loader;

/**
 * @author Team 7 PT
 * @version 1.0
 */
import com.vcms.entity.store.item.CashStoreItem;
import com.vcms.entity.store.itemtype.Coin;

public class CashPropertyLoader extends PropertyLoader {

	public CashPropertyLoader(String filen) {
		super(filen);
	}

	public CashStoreItem getItem(int idx) {
		CashStoreItem cit;

		Coin cn = new Coin();
		String item, itemv;

		item = new String("Name" + idx);
		itemv = getValue(item);
		cn.setName(itemv);

		item = new String("Weight" + idx);
		itemv = getValue(item);
		cn.setWeight(Double.parseDouble(itemv));

		item = new String("Value" + idx);
		itemv = getValue(item);
		cn.setValue(Integer.parseInt(itemv));

		item = new String("Quantity" + idx);
		itemv = getValue(item);

		cit = new CashStoreItem(cn, Integer.parseInt(itemv));

		return cit;
	}

	public void setItem(int it, CashStoreItem item) {
		String itn;
		Coin cn;
		int idx = it + 1;

		cn = (Coin) item.getContent();
		itn = new String("Name" + idx);

		setValue(itn, cn.getName());

		itn = new String("Weight" + idx);
		setValue(itn, String.valueOf(cn.getWeight()));

		itn = new String("Value" + idx);
		setValue(itn, String.valueOf(cn.getValue()));

		itn = new String("Quantity" + idx);
		setValue(itn, String.valueOf(item.getQuantity()));
	}

}